api = {
    POST: function(url, data, callback) {
        axios({
            method: 'post',
            url: base+url,
            data: JSON.stringify(data),
            headers: {
                'Token': localStorage.getItem('Token'),
                'Redirect-Header': false,
                'Content-Type': 'application/json',
                'X-XSRF-TOKEN':initCookies()['X-XSRF-TOKEN'] || initCookies()['XSRF-TOKEN']
            }
        }).then(function(response) {
            if (response.status == 200) {
                callback(response.data)
            } else {
                errorTip(response.data.message)
            }
        }).catch(function(error) {
            console.log(error)
        })
    },
    GET: function(url, data, callback) {
        axios({
            method: 'get',
            url: base+url,
            params: data,
            headers: {
                'Token': localStorage.getItem('Token'),
                'Redirect-Header': false,
                'Content-Type': 'application/json'
            }
        }).then(function(response) {
            if (response.status == 200) {
                callback(response.data)
            } else {
                errorTip(response.data.message)
            }
        }).catch(function(error) {
            console.log(error)
        })
    },
    PUT: function(url, data, callback) {
        axios({
            method: 'put',
            url: base+url,
            data: JSON.stringify(data),
            headers: {
                'Token': localStorage.getItem('Token'),
                'Redirect-Header': false,
                'Content-Type': 'application/json',
                'X-XSRF-TOKEN':initCookies()['X-XSRF-TOKEN'] || initCookies()['XSRF-TOKEN']
            }
        }).then(function(response) {
            if (response.status == 200) {
                callback(response.data)
            } else {
                errorTip(response.data.message)
            }
        }).catch(function(error) {
            console.log(error)
        })
    },
    DELETE: function(url, data, callback) {
        axios({
            method: 'post',
            url: base+url+'/delete',
            data: JSON.stringify(data),
            headers: {
                'Token': localStorage.getItem('Token'),
                'Redirect-Header': false,
                'Content-Type': 'application/json',
                'X-XSRF-TOKEN':initCookies()['X-XSRF-TOKEN'] || initCookies()['XSRF-TOKEN']
            }
        }).then(function(response) {
            if (response.status == 200) {
                callback(response.data)
            } else {
                errorTip(response.data.message)
            }
        }).catch(function(error) {
            console.log(error)
        })
    }
}
